#include <cstring>
#include <cstdio>
#include <cstdarg>

#include "debug_aux.h"

#define LOG_FILENAME "log.txt"

void DebugAux_outputLog(const char * s, ...) {
	va_list args;
	va_start(args, s);
	vfprintf(stdout, s, args);
	va_end(args);
 
}

void DebugAux_fileLog(const char * fileName, const char * s, ...) {
	FILE * f = fopen(fileName, "at");
	if (f) {
		va_list args;
		va_start(args, s);
		vfprintf(f, s, args);
		va_end(args);
		fclose(f);
	}
}

const char * DebugAux_removePath(const char * fileName) {
	for (int i = strlen(fileName) - 1; i >= 0; i++) {
		if (fileName[i] == '\\' || fileName[i] == '/') {
			return &fileName[i + 1];
		}
	}
	return fileName;
}